.class public Lcom/evernote/client/android/EvernoteSession;
.super Ljava/lang/Object;
.source "EvernoteSession.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/evernote/client/android/EvernoteSession$EvernoteService;
    }
.end annotation


# static fields
.field public static final HOST_CHINA:Ljava/lang/String; = "https://app.yinxiang.com"

.field public static final HOST_PRODUCTION:Ljava/lang/String; = "https://www.evernote.com"

.field public static final HOST_SANDBOX:Ljava/lang/String; = "https://sandbox.evernote.com"

.field private static final LOGTAG:Ljava/lang/String; = "EvernoteSession"

.field public static final REQUEST_CODE_CREATE:I = 0x3837

.field public static final REQUEST_CODE_OAUTH:I = 0x3836

.field public static final RESULT_CODE_FAILURE:I = 0x2710

.field private static sInstance:Lcom/evernote/client/android/EvernoteSession;


# instance fields
.field private mAuthenticationResult:Lcom/evernote/client/android/AuthenticationResult;

.field private mBootstrapManager:Lcom/evernote/client/android/BootstrapManager;

.field private mClientFactory:Lcom/evernote/client/android/ClientFactory;

.field private mConsumerKey:Ljava/lang/String;

.field private mConsumerSecret:Ljava/lang/String;

.field private mEvernoteService:Lcom/evernote/client/android/EvernoteSession$EvernoteService;

.field private mSupportAppLinkedNotebooks:Z


# direct methods
.method static constructor <clinit>()V
    .registers 1

    .prologue
    .line 127
    const/4 v0, 0x0

    sput-object v0, Lcom/evernote/client/android/EvernoteSession;->sInstance:Lcom/evernote/client/android/EvernoteSession;

    return-void
.end method

.method private constructor <init>(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Lcom/evernote/client/android/EvernoteSession$EvernoteService;Z)V
    .registers 9
    .param p1, "ctx"    # Landroid/content/Context;
    .param p2, "consumerKey"    # Ljava/lang/String;
    .param p3, "consumerSecret"    # Ljava/lang/String;
    .param p4, "evernoteService"    # Lcom/evernote/client/android/EvernoteSession$EvernoteService;
    .param p5, "supportAppLinkedNotebooks"    # Z
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalArgumentException;
        }
    .end annotation

    .prologue
    .line 178
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 180
    if-eqz p1, :cond_13

    invoke-static {p2}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-nez v0, :cond_13

    invoke-static {p3}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-nez v0, :cond_13

    if-nez p4, :cond_1b

    .line 181
    :cond_13
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "Parameters canot be null or empty"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 184
    :cond_1b
    iput-object p2, p0, Lcom/evernote/client/android/EvernoteSession;->mConsumerKey:Ljava/lang/String;

    .line 185
    iput-object p3, p0, Lcom/evernote/client/android/EvernoteSession;->mConsumerSecret:Ljava/lang/String;

    .line 186
    iput-object p4, p0, Lcom/evernote/client/android/EvernoteSession;->mEvernoteService:Lcom/evernote/client/android/EvernoteSession$EvernoteService;

    .line 187
    iput-boolean p5, p0, Lcom/evernote/client/android/EvernoteSession;->mSupportAppLinkedNotebooks:Z

    .line 188
    monitor-enter p0

    .line 189
    :try_start_24
    invoke-static {p1}, Lcom/evernote/client/android/SessionPreferences;->getPreferences(Landroid/content/Context;)Landroid/content/SharedPreferences;

    move-result-object v0

    invoke-direct {p0, v0}, Lcom/evernote/client/android/EvernoteSession;->getAuthenticationResultFromPref(Landroid/content/SharedPreferences;)Lcom/evernote/client/android/AuthenticationResult;

    move-result-object v0

    iput-object v0, p0, Lcom/evernote/client/android/EvernoteSession;->mAuthenticationResult:Lcom/evernote/client/android/AuthenticationResult;

    .line 190
    monitor-exit p0
    :try_end_2f
    .catchall {:try_start_24 .. :try_end_2f} :catchall_4a

    .line 191
    new-instance v0, Lcom/evernote/client/android/ClientFactory;

    invoke-direct {p0, p1}, Lcom/evernote/client/android/EvernoteSession;->generateUserAgentString(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {p1}, Landroid/content/Context;->getFilesDir()Ljava/io/File;

    move-result-object v2

    invoke-direct {v0, v1, v2}, Lcom/evernote/client/android/ClientFactory;-><init>(Ljava/lang/String;Ljava/io/File;)V

    iput-object v0, p0, Lcom/evernote/client/android/EvernoteSession;->mClientFactory:Lcom/evernote/client/android/ClientFactory;

    .line 192
    new-instance v0, Lcom/evernote/client/android/BootstrapManager;

    iget-object v1, p0, Lcom/evernote/client/android/EvernoteSession;->mEvernoteService:Lcom/evernote/client/android/EvernoteSession$EvernoteService;

    iget-object v2, p0, Lcom/evernote/client/android/EvernoteSession;->mClientFactory:Lcom/evernote/client/android/ClientFactory;

    invoke-direct {v0, v1, v2}, Lcom/evernote/client/android/BootstrapManager;-><init>(Lcom/evernote/client/android/EvernoteSession$EvernoteService;Lcom/evernote/client/android/ClientFactory;)V

    iput-object v0, p0, Lcom/evernote/client/android/EvernoteSession;->mBootstrapManager:Lcom/evernote/client/android/BootstrapManager;

    .line 193
    return-void

    .line 190
    :catchall_4a
    move-exception v0

    :try_start_4b
    monitor-exit p0
    :try_end_4c
    .catchall {:try_start_4b .. :try_end_4c} :catchall_4a

    throw v0
.end method

.method private generateUserAgentString(Landroid/content/Context;)Ljava/lang/String;
    .registers 9
    .param p1, "ctx"    # Landroid/content/Context;

    .prologue
    .line 253
    const/4 v2, 0x0

    .line 254
    .local v2, "packageName":Ljava/lang/String;
    const/4 v3, 0x0

    .line 256
    .local v3, "packageVersion":I
    :try_start_2
    invoke-virtual {p1}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v2

    .line 257
    invoke-virtual {p1}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v5

    const/4 v6, 0x0

    invoke-virtual {v5, v2, v6}, Landroid/content/pm/PackageManager;->getPackageInfo(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;

    move-result-object v5

    iget v3, v5, Landroid/content/pm/PackageInfo;->versionCode:I
    :try_end_11
    .catch Landroid/content/pm/PackageManager$NameNotFoundException; {:try_start_2 .. :try_end_11} :catch_92

    .line 263
    :goto_11
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, " Android/"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    .line 265
    .local v4, "userAgent":Ljava/lang/String;
    invoke-static {}, Ljava/util/Locale;->getDefault()Ljava/util/Locale;

    move-result-object v1

    .line 266
    .local v1, "locale":Ljava/util/Locale;
    if-nez v1, :cond_9e

    .line 267
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v5, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, " ("

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    sget-object v6, Ljava/util/Locale;->US:Ljava/util/Locale;

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, ");"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    .line 271
    :goto_4d
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v5, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, "Android/"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    sget-object v6, Landroid/os/Build$VERSION;->RELEASE:Ljava/lang/String;

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, "; "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    .line 272
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v5, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    sget-object v6, Landroid/os/Build;->MODEL:Ljava/lang/String;

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, "/"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    sget v6, Landroid/os/Build$VERSION;->SDK_INT:I

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, ";"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    .line 273
    return-object v4

    .line 259
    .end local v1    # "locale":Ljava/util/Locale;
    .end local v4    # "userAgent":Ljava/lang/String;
    :catch_92
    move-exception v0

    .line 260
    .local v0, "e":Landroid/content/pm/PackageManager$NameNotFoundException;
    const-string v5, "EvernoteSession"

    invoke-virtual {v0}, Landroid/content/pm/PackageManager$NameNotFoundException;->getMessage()Ljava/lang/String;

    move-result-object v6

    invoke-static {v5, v6}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    goto/16 :goto_11

    .line 269
    .end local v0    # "e":Landroid/content/pm/PackageManager$NameNotFoundException;
    .restart local v1    # "locale":Ljava/util/Locale;
    .restart local v4    # "userAgent":Ljava/lang/String;
    :cond_9e
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v5, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, " ("

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v1}, Ljava/util/Locale;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, "); "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    goto :goto_4d
.end method

.method private getAuthenticationResultFromPref(Landroid/content/SharedPreferences;)Lcom/evernote/client/android/AuthenticationResult;
    .registers 4
    .param p1, "prefs"    # Landroid/content/SharedPreferences;

    .prologue
    .line 216
    new-instance v0, Lcom/evernote/client/android/AuthenticationResult;

    invoke-direct {v0, p1}, Lcom/evernote/client/android/AuthenticationResult;-><init>(Landroid/content/SharedPreferences;)V

    .line 218
    .local v0, "authResult":Lcom/evernote/client/android/AuthenticationResult;
    invoke-virtual {v0}, Lcom/evernote/client/android/AuthenticationResult;->getEvernoteHost()Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v1

    if-nez v1, :cond_37

    invoke-virtual {v0}, Lcom/evernote/client/android/AuthenticationResult;->getAuthToken()Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v1

    if-nez v1, :cond_37

    invoke-virtual {v0}, Lcom/evernote/client/android/AuthenticationResult;->getNoteStoreUrl()Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v1

    if-nez v1, :cond_37

    .line 219
    invoke-virtual {v0}, Lcom/evernote/client/android/AuthenticationResult;->getWebApiUrlPrefix()Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v1

    if-nez v1, :cond_37

    invoke-virtual {v0}, Lcom/evernote/client/android/AuthenticationResult;->getEvernoteHost()Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v1

    if-eqz v1, :cond_38

    .line 220
    :cond_37
    const/4 v0, 0x0

    .line 223
    .end local v0    # "authResult":Lcom/evernote/client/android/AuthenticationResult;
    :cond_38
    return-object v0
.end method

.method public static getInstance(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Lcom/evernote/client/android/EvernoteSession$EvernoteService;Z)Lcom/evernote/client/android/EvernoteSession;
    .registers 11
    .param p0, "ctx"    # Landroid/content/Context;
    .param p1, "consumerKey"    # Ljava/lang/String;
    .param p2, "consumerSecret"    # Ljava/lang/String;
    .param p3, "evernoteService"    # Lcom/evernote/client/android/EvernoteSession$EvernoteService;
    .param p4, "supportAppLinkedNotebooks"    # Z
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalArgumentException;
        }
    .end annotation

    .prologue
    .line 157
    sget-object v0, Lcom/evernote/client/android/EvernoteSession;->sInstance:Lcom/evernote/client/android/EvernoteSession;

    if-nez v0, :cond_10

    .line 158
    new-instance v0, Lcom/evernote/client/android/EvernoteSession;

    move-object v1, p0

    move-object v2, p1

    move-object v3, p2

    move-object v4, p3

    move v5, p4

    invoke-direct/range {v0 .. v5}, Lcom/evernote/client/android/EvernoteSession;-><init>(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Lcom/evernote/client/android/EvernoteSession$EvernoteService;Z)V

    sput-object v0, Lcom/evernote/client/android/EvernoteSession;->sInstance:Lcom/evernote/client/android/EvernoteSession;

    .line 160
    :cond_10
    sget-object v0, Lcom/evernote/client/android/EvernoteSession;->sInstance:Lcom/evernote/client/android/EvernoteSession;

    return-object v0
.end method

.method static getOpenSession()Lcom/evernote/client/android/EvernoteSession;
    .registers 1

    .prologue
    .line 171
    sget-object v0, Lcom/evernote/client/android/EvernoteSession;->sInstance:Lcom/evernote/client/android/EvernoteSession;

    return-object v0
.end method


# virtual methods
.method public authenticate(Landroid/content/Context;)V
    .registers 5
    .param p1, "ctx"    # Landroid/content/Context;

    .prologue
    .line 283
    new-instance v0, Landroid/content/Intent;

    const-class v1, Lcom/evernote/client/android/EvernoteOAuthActivity;

    invoke-direct {v0, p1, v1}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    .line 284
    .local v0, "intent":Landroid/content/Intent;
    const-string v1, "EVERNOTE_HOST"

    iget-object v2, p0, Lcom/evernote/client/android/EvernoteSession;->mEvernoteService:Lcom/evernote/client/android/EvernoteSession$EvernoteService;

    invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;

    .line 285
    const-string v1, "CONSUMER_KEY"

    iget-object v2, p0, Lcom/evernote/client/android/EvernoteSession;->mConsumerKey:Ljava/lang/String;

    invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 286
    const-string v1, "CONSUMER_SECRET"

    iget-object v2, p0, Lcom/evernote/client/android/EvernoteSession;->mConsumerSecret:Ljava/lang/String;

    invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 287
    const-string v1, "SUPPORT_APP_LINKED_NOTEBOOKS"

    iget-boolean v2, p0, Lcom/evernote/client/android/EvernoteSession;->mSupportAppLinkedNotebooks:Z

    invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Z)Landroid/content/Intent;

    .line 289
    instance-of v1, p1, Landroid/app/Activity;

    if-eqz v1, :cond_2f

    .line 291
    check-cast p1, Landroid/app/Activity;

    .end local p1    # "ctx":Landroid/content/Context;
    const/16 v1, 0x3836

    invoke-virtual {p1, v0, v1}, Landroid/app/Activity;->startActivityForResult(Landroid/content/Intent;I)V

    .line 299
    :goto_2e
    return-void

    .line 295
    .restart local p1    # "ctx":Landroid/content/Context;
    :cond_2f
    const/high16 v1, 0x10000000

    invoke-virtual {v0, v1}, Landroid/content/Intent;->addFlags(I)Landroid/content/Intent;

    .line 296
    invoke-virtual {p1, v0}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V

    goto :goto_2e
.end method

.method public getAuthToken()Ljava/lang/String;
    .registers 2

    .prologue
    .line 232
    iget-object v0, p0, Lcom/evernote/client/android/EvernoteSession;->mAuthenticationResult:Lcom/evernote/client/android/AuthenticationResult;

    if-eqz v0, :cond_b

    .line 233
    iget-object v0, p0, Lcom/evernote/client/android/EvernoteSession;->mAuthenticationResult:Lcom/evernote/client/android/AuthenticationResult;

    invoke-virtual {v0}, Lcom/evernote/client/android/AuthenticationResult;->getAuthToken()Ljava/lang/String;

    move-result-object v0

    .line 235
    :goto_a
    return-object v0

    :cond_b
    const/4 v0, 0x0

    goto :goto_a
.end method

.method public getAuthenticationResult()Lcom/evernote/client/android/AuthenticationResult;
    .registers 2

    .prologue
    .line 243
    iget-object v0, p0, Lcom/evernote/client/android/EvernoteSession;->mAuthenticationResult:Lcom/evernote/client/android/AuthenticationResult;

    return-object v0
.end method

.method protected getBootstrapSession()Lcom/evernote/client/android/BootstrapManager;
    .registers 2

    .prologue
    .line 200
    iget-object v0, p0, Lcom/evernote/client/android/EvernoteSession;->mBootstrapManager:Lcom/evernote/client/android/BootstrapManager;

    return-object v0
.end method

.method public getClientFactory()Lcom/evernote/client/android/ClientFactory;
    .registers 2

    .prologue
    .line 207
    iget-object v0, p0, Lcom/evernote/client/android/EvernoteSession;->mClientFactory:Lcom/evernote/client/android/ClientFactory;

    return-object v0
.end method

.method public isAppLinkedNotebook()Z
    .registers 2

    .prologue
    .line 336
    iget-object v0, p0, Lcom/evernote/client/android/EvernoteSession;->mAuthenticationResult:Lcom/evernote/client/android/AuthenticationResult;

    invoke-virtual {v0}, Lcom/evernote/client/android/AuthenticationResult;->isAppLinkedNotebook()Z

    move-result v0

    return v0
.end method

.method public isLoggedIn()Z
    .registers 2

    .prologue
    .line 330
    monitor-enter p0

    .line 331
    :try_start_1
    iget-object v0, p0, Lcom/evernote/client/android/EvernoteSession;->mAuthenticationResult:Lcom/evernote/client/android/AuthenticationResult;

    if-eqz v0, :cond_8

    const/4 v0, 0x1

    :goto_6
    monitor-exit p0

    return v0

    :cond_8
    const/4 v0, 0x0

    goto :goto_6

    .line 332
    :catchall_a
    move-exception v0

    monitor-exit p0
    :try_end_c
    .catchall {:try_start_1 .. :try_end_c} :catchall_a

    throw v0
.end method

.method public logOut(Landroid/content/Context;)V
    .registers 5
    .param p1, "ctx"    # Landroid/content/Context;
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/evernote/client/android/InvalidAuthenticationException;
        }
    .end annotation

    .prologue
    .line 343
    invoke-virtual {p0}, Lcom/evernote/client/android/EvernoteSession;->isLoggedIn()Z

    move-result v1

    if-nez v1, :cond_e

    .line 344
    new-instance v1, Lcom/evernote/client/android/InvalidAuthenticationException;

    const-string v2, "Must not call when already logged out"

    invoke-direct {v1, v2}, Lcom/evernote/client/android/InvalidAuthenticationException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 346
    :cond_e
    monitor-enter p0

    .line 347
    :try_start_f
    iget-object v1, p0, Lcom/evernote/client/android/EvernoteSession;->mAuthenticationResult:Lcom/evernote/client/android/AuthenticationResult;

    invoke-static {p1}, Lcom/evernote/client/android/SessionPreferences;->getPreferences(Landroid/content/Context;)Landroid/content/SharedPreferences;

    move-result-object v2

    invoke-virtual {v1, v2}, Lcom/evernote/client/android/AuthenticationResult;->clear(Landroid/content/SharedPreferences;)V

    .line 348
    const/4 v1, 0x0

    iput-object v1, p0, Lcom/evernote/client/android/EvernoteSession;->mAuthenticationResult:Lcom/evernote/client/android/AuthenticationResult;

    .line 349
    monitor-exit p0
    :try_end_1c
    .catchall {:try_start_f .. :try_end_1c} :catchall_27

    .line 353
    invoke-static {p1}, Landroid/webkit/CookieSyncManager;->createInstance(Landroid/content/Context;)Landroid/webkit/CookieSyncManager;

    .line 354
    invoke-static {}, Landroid/webkit/CookieManager;->getInstance()Landroid/webkit/CookieManager;

    move-result-object v0

    .line 355
    .local v0, "cookieManager":Landroid/webkit/CookieManager;
    invoke-virtual {v0}, Landroid/webkit/CookieManager;->removeAllCookie()V

    .line 356
    return-void

    .line 349
    .end local v0    # "cookieManager":Landroid/webkit/CookieManager;
    :catchall_27
    move-exception v1

    :try_start_28
    monitor-exit p0
    :try_end_29
    .catchall {:try_start_28 .. :try_end_29} :catchall_27

    throw v1
.end method

.method protected persistAuthenticationToken(Landroid/content/Context;Lcom/evernote/client/oauth/EvernoteAuthToken;Ljava/lang/String;)Z
    .registers 11
    .param p1, "ctx"    # Landroid/content/Context;
    .param p2, "authToken"    # Lcom/evernote/client/oauth/EvernoteAuthToken;
    .param p3, "evernoteHost"    # Ljava/lang/String;

    .prologue
    .line 313
    if-eqz p1, :cond_4

    if-nez p2, :cond_6

    .line 314
    :cond_4
    const/4 v0, 0x0

    .line 323
    :goto_5
    return v0

    .line 316
    :cond_6
    monitor-enter p0

    .line 317
    :try_start_7
    new-instance v0, Lcom/evernote/client/android/AuthenticationResult;

    invoke-virtual {p2}, Lcom/evernote/client/oauth/EvernoteAuthToken;->getToken()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {p2}, Lcom/evernote/client/oauth/EvernoteAuthToken;->getNoteStoreUrl()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {p2}, Lcom/evernote/client/oauth/EvernoteAuthToken;->getWebApiUrlPrefix()Ljava/lang/String;

    move-result-object v3

    .line 318
    invoke-virtual {p2}, Lcom/evernote/client/oauth/EvernoteAuthToken;->getUserId()I

    move-result v5

    invoke-virtual {p2}, Lcom/evernote/client/oauth/EvernoteAuthToken;->isAppLinkedNotebook()Z

    move-result v6

    move-object v4, p3

    invoke-direct/range {v0 .. v6}, Lcom/evernote/client/android/AuthenticationResult;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)V

    iput-object v0, p0, Lcom/evernote/client/android/EvernoteSession;->mAuthenticationResult:Lcom/evernote/client/android/AuthenticationResult;

    .line 320
    iget-object v0, p0, Lcom/evernote/client/android/EvernoteSession;->mAuthenticationResult:Lcom/evernote/client/android/AuthenticationResult;

    invoke-static {p1}, Lcom/evernote/client/android/SessionPreferences;->getPreferences(Landroid/content/Context;)Landroid/content/SharedPreferences;

    move-result-object v1

    invoke-virtual {v0, v1}, Lcom/evernote/client/android/AuthenticationResult;->persist(Landroid/content/SharedPreferences;)V

    .line 321
    monitor-exit p0

    .line 323
    const/4 v0, 0x1

    goto :goto_5

    .line 321
    :catchall_2f
    move-exception v0

    monitor-exit p0
    :try_end_31
    .catchall {:try_start_7 .. :try_end_31} :catchall_2f

    throw v0
.end method
